﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UIFire : MonoBehaviour
{
    List<GameObject> items = new List<GameObject>();
    public Fire fire;
    List<Object> objects = new List<Object>();

    // Start is called before the first frame update
    void Start()
    {
        var trans = transform.Find("Items");
        var obj1 = Resources.Load("rou");
        objects.Add(obj1);
        var obj2 = Resources.Load("mogu");
        objects.Add(obj2);
        for (int i = 0; i < trans.childCount; i++)
        {
            int a = i;
            items.Add(trans.GetChild(a).gameObject);
            UGUIEventListener.Get(items[a]).onClick = (obj) =>
            {
                if (a < 2)
                {
                    var go = Instantiate(objects[a]) as GameObject;
                    fire.AddItem(go);
                }
                trans.parent.gameObject.SetActive(false);
            };
        }
    }

    // Update is called once per frame
    void Update()
    {

    }
}
